package com.shuihu.liutang;
/*
 * Help Information
 *
 * Create Date:2017/4/13
 *
 * zhangle
 */

import com.shuihu.liutang.configuration.Configuration;
import com.shuihu.liutang.redis.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;

public class Main {

    private static final Logger LOG = LoggerFactory.getLogger(Main.class);

    private static void usage() {
        String usage = "java -jar xxx.jar type filename";
        System.out.println(usage);
    }

    public static void main(String[] args) throws Exception {
        if (2 != args.length) {
            usage();
            System.exit(1);
        }
        String type = args[0];
        String path = args[1];

        AbsFileImporter absFileImporter = null;
        if (type.equals("matrix")) {
            absFileImporter = new MatrixFileImporter();
        }else if (type.equals("artificialbook")){
            absFileImporter = new ArtificialBooklistImporter();
        }else if (type.equals("favorauthorbook")) {
            absFileImporter = new FavorAuthorBooklistImporter();
        }else if (type.equals("favorbook")) {
            absFileImporter = new FavorBooklistImporter();
        }else if (type.equals("favorc3book")) {
            absFileImporter = new FavorC3BooklistImporter();
        }
        String host = Configuration.getProperty("redis.host");
        String port = Configuration.getProperty("redis.port");
        LOG.debug("params:{}-{}-{}", host, port, path);
        absFileImporter.init(host, port);
        absFileImporter.importFile(new File(path));
    }
}
